@extends('admin.layouts.main')
@section('header')
    @parent
@endsection
@section('content')
    <form class="layui-form">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">账号</label>
                <div class="layui-input-inline">
                    <input type="search" class="layui-input accountInput" disabled placeholder="账号">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">手机</label>
                <div class="layui-input-inline">
                    <input type="tel" class="layui-input" name="tel" placeholder="手机号">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">昵称</label>
                <div class="layui-input-inline">
                    <input type="search" class="layui-input" name="nickname" placeholder="昵称">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline">
                    <input type="search" class="layui-input" name="name" placeholder="姓名">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-inline">
                    <input type="password" class="layui-input" name="password" placeholder="不填则不修改">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">确认密码</label>
                <div class="layui-input-inline">
                    <input type="password" class="layui-input" name="re_password" placeholder="确认密码">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block">
                    <input type="radio" name="sex" value="1" title="男">
                    <input type="radio" name="sex" value="2"  title="女">
                    <input type="radio" name="sex" value="0"  title="保密">
                </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-inline">
                    <input type="radio" name="status" value="1" title="正常">
                    <input type="radio" name="status" value="0"  title="禁用">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">头像</label>
            <div class="layui-input-block">
                <span class="layui-btn image-upload-btn" id="upload-btn">上传</span>
                <input class="upload-image" type="file" style="display: none" data-tag="avatar" data-field="avatar" data-multi="0" data-url="{{ url('admin/upload/image') }}">
                <div class="image-preview-box"></div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <input type="hidden" name="id" value="">
                <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="submit">立即提交</button>
            </div>
        </div>
    </form>
@endsection
@section('footer')
    @parent
    <script type="text/javascript">
       layui.use(['layer','jquery','form'],function () {
           var layer = layui.layer,
               $ = layui.jquery,
               form = layui.form;
           form.on("submit(submit)",function (data) {
               var formData = data.field;
                goConfirm('{{ url('admin/admin/edit') }}',formData,'确认提交数据',1);
               return false;
           });
           getDetail();
           function getDetail() {
               var id = getUrlParam('id');
               $("input[name='id']").val(id);
               $.get('{{ url('admin/admin/detail') }}',{id:id},function (res) {
                   if(res.status == 200){
                       var data = res.data;
                       $('.accountInput').val(data.account);
                       $("input[name='tel']").val(data.tel);
                       $("input[name='nickname']").val(data.nickname);
                       $("input[name='name']").val(data.name);
                       $("input[name='sex'][value='"+data.sex+"']").attr('checked',true);
                       $("input[name='status'][value='"+data.status+"']").attr('checked',true);
                       if(data.avatar){
                           $('.image-preview-box').html(createImageBox(data.id,'avatar',data.avatar))
                       }
                       form.render();

                   }
               },'json')
           }
       });



    </script>
@endsection